//
//  HallViewController.m
//  MyLottery
//
//  Created by wpapple on 16/5/24.
//  Copyright © 2016年 wpapple. All rights reserved.
//

#import "HallViewController.h"

@interface HallViewController ()

@property (nonatomic,weak) UIView *coverView;

@property (nonatomic,weak) UIImageView *imageView;

@end

@implementation HallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)BtnClicked:(UIButton *)sender {
    
    UIView *coverView = [[UIView alloc]init];
    
    coverView.frame = [UIScreen mainScreen].bounds;
    
    [coverView setBackgroundColor:[UIColor blackColor]];
    
    coverView.alpha = 0.5;
    
    self.coverView = coverView;
    
    [self.tabBarController.view addSubview:coverView];
    
    
    
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cover"]];
    
    imageView.center = coverView.center;
    
    self.imageView = imageView;
    
    self.imageView.userInteractionEnabled = YES;
    
    [self.tabBarController.view addSubview:imageView];
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn setBackgroundImage:[UIImage imageNamed:@"ArenaHall_Close"] forState:UIControlStateNormal];
    
    btn.x = self.imageView.size.width - 23;
    btn.y = 0;
    btn.width = 23;
    btn.height = btn.width;
    
    [imageView addSubview:btn];
    
    [btn addTarget:self action:@selector(remCoverClick) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)remCoverClick
{
    [UIView animateWithDuration:1 animations:^{
        
        self.imageView.alpha = 0;
        self.coverView.alpha = 0;
        
    }completion:^(BOOL finished) {
        [self.coverView removeFromSuperview];
        [self.imageView removeFromSuperview];
    }];
}



@end
